<% content_for :head do %>
  <%= javascript_include_tag "https://www.google.com/jsapi" %>
  <%= javascript_include_tag "forecast_tests" %>
<% end %>

<table class="box-table">
  <thead>
	  <tr>
	    <th scope="col">Test Execution Date</th>
	    <th scope="col">Algorithm Name</th>
	    <th scope="col">Algorithm Version</th>
	    <th scope="col">Device Model</th>
	    <th scope="col">SO Version</th>
	    <th scope="col">Forecast Horizon</th>
	    <th scope="col">Duration (ms)</th>
	    <th scope="col">Memory Used (kb)</th>
	    <th scope="col">Energy Used (J)</th>
	    <th scope="col">MAE (min)</th>
	    <th scope="col">MAPE (min)</th>
	    
	    <!-- Test Base Data -->
	    <th scope="col">Base Data Created At</th>
	    <th scope="col">Base Data Type</th>
	    <th scope="col">UserUUID</th>
	    <th scope="col">Used Threshold</th>
	    <th scope="col">Used Days Ago</th>
	  </tr>
  </thead>

	<tbody>
	<% if !@test_log.nil? %>
	  <tr>
	    <td><%= @test_log.executed_at-3.hours %></td>
	    <td><%= @test_log.algorithm_name %></td>
	    <td><%= @test_log.algorithm_version %></td>
	    <td><%= @test_log.device_model %></td>
	    <td><%= @test_log.SO_version %></td>
	    <td><%= @test_log.forecast_horizon %></td>
	    <td><%= @test_log.duration %></td>
	    <td><%= number_with_precision(@test_log.memory_used/1024, precision: 2) %></td>
	    <td><%= number_with_precision(@test_log.energy_used, precision: 2) %></td>
	    <td><%= number_with_precision(TestLog.get_mean_absolute_error(@test_log, @test_log.forecast_horizon), precision: 2) %></td>
	    <td><%= number_to_percentage(TestLog.get_mean_absolute_percentage_error(@test_log), precision: 2) %></td>
	    <td><%= @test_log.test_base_data.base_data_created_at-3.hours %></td>
    	<td><%= @test_log.test_base_data.base_data_type %></td>
	    <td><%= @test_log.test_base_data.user_uuid %></td>
	    <td><%= @test_log.test_base_data.used_threshold %></td>
	    <td><%= @test_log.test_base_data.used_days_ago %></td>
	  </tr>
	<% end %>
	</tbody>
</table>

<div id='forecast_test_result_chart'></div>